package com.ibeeking.found.common.config.feign.fallback;

import com.ibeeking.found.common.config.feign.MemberJobFeignClient;
import com.ibeeking.found.common.entity.TimeTaskJobParam;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class MemberJobFeignClientFallbackFactory implements FallbackFactory<MemberJobFeignClient> {
    @Override
    public MemberJobFeignClient create(Throwable throwable) {
        return new MemberJobFeignClient() {
            @Override
            public ResponseResult<Boolean>  createJobInfoForMemberSurvey(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，创建会员情况统计任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public  ResponseResult<Boolean>  delJobInfoForMemberUsageSurvey(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，删除会员情况统计任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public ResponseResult<Boolean>  createJobInfoForAutoCalculateLevel(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，创建自动计算会员等级任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public  ResponseResult<Boolean>  delJobInfoForAutoCalculateLevel(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，删除自动计算会员等级任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public ResponseResult<Boolean>  createJobInfoForAutoTags(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，创建自动添加标签任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public  ResponseResult<Boolean>  delJobInfoForAutoTags(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，删除自动添加标签任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public ResponseResult<Boolean>  createJobInfoForAutoPointExpire(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，创建自动积分失效任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public  ResponseResult<Boolean>  delJobInfoForAutoPointExpire(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，删除自动积分失效任务ID失败。" + throwable.getMessage(), true);
            }

        };
    }
}
